<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

    <title>cup.shell package &#8212; cup 3.2.33 documentation</title>
    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
    <script src="_static/doctools.js"></script>
    <script src="_static/sphinx_highlight.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="cup.storage package" href="cup.storage.html" />
    <link rel="prev" title="cup.services package" href="cup.services.html" />
   
  <link rel="stylesheet" href="_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <section id="module-cup.shell">
<span id="cup-shell-package"></span><h1>cup.shell package<a class="headerlink" href="#module-cup.shell" title="Permalink to this heading">¶</a></h1>
<dl class="field-list simple">
<dt class="field-odd">description<span class="colon">:</span></dt>
<dd class="field-odd"><p>shell related module</p>
</dd>
</dl>
<section id="submodules">
<h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this heading">¶</a></h2>
</section>
<section id="module-cup.shell.expect">
<span id="cup-shell-expect-module"></span><h2>cup.shell.expect module<a class="headerlink" href="#module-cup.shell.expect" title="Permalink to this heading">¶</a></h2>
<dl class="field-list simple">
<dt class="field-odd">description<span class="colon">:</span></dt>
<dd class="field-odd"><p>made a wraper out of paramiko.**
The original copyright belongs to the author of paramiko module.
See it at <a class="reference external" href="http://docs.paramiko.org/en/stable/">http://docs.paramiko.org/en/stable/</a></p>
</dd>
</dl>
<dl class="py function">
<dt class="sig sig-object py" id="cup.shell.expect.checkssh">
<span class="sig-prename descclassname"><span class="pre">cup.shell.expect.</span></span><span class="sig-name descname"><span class="pre">checkssh</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">hostname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">username</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">passwd</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/cup/shell/expect.html#checkssh"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#cup.shell.expect.checkssh" title="Permalink to this definition">¶</a></dt>
<dd><p>check if we can ssh to hostname.
:return:a dict with keys (‘exitstatus’, ‘result’) exitstatus 0 success -1 others</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="cup.shell.expect.dscp">
<span class="sig-prename descclassname"><span class="pre">cup.shell.expect.</span></span><span class="sig-name descname"><span class="pre">dscp</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">hostname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">username</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">passwd</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">src</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dst</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timeout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">9000</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/cup/shell/expect.html#dscp"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#cup.shell.expect.dscp" title="Permalink to this definition">¶</a></dt>
<dd><p>copy [hostname]:[src] to [localhost]:[dst].</p>
<dl class="field-list simple">
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p>a dict with keys (‘exitstatus’, ‘result’) exitstatus 0 success -1 others</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="cup.shell.expect.go_ex">
<span class="sig-prename descclassname"><span class="pre">cup.shell.expect.</span></span><span class="sig-name descname"><span class="pre">go_ex</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">hostname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">username</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">passwd</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">command</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timeout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">600</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b_print_stdout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/cup/shell/expect.html#go_ex"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#cup.shell.expect.go_ex" title="Permalink to this definition">¶</a></dt>
<dd><p>execute command at remote.
:return:a dict with keys (‘exitstatus’, ‘result’) exitstatus 0 success -1 others</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="cup.shell.expect.go_with_scp">
<span class="sig-prename descclassname"><span class="pre">cup.shell.expect.</span></span><span class="sig-name descname"><span class="pre">go_with_scp</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">hostname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">username</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">passwd</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">command</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">host_tmp</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'/tmp/'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">remote_tmp</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'/tmp/'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timeout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">800</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/cup/shell/expect.html#go_with_scp"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#cup.shell.expect.go_with_scp" title="Permalink to this definition">¶</a></dt>
<dd><p>Recommand using this function to remotely execute cmds.</p>
<p>go_witch_scp will write a temp script file and scp to hostname:[host_tmp].
Then execute it and get the result back.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>host_tmp</strong> – temp folder for keeping the temporary script file (contains the cmd)</p></li>
<li><p><strong>remote_tmp</strong> – remote temp folder for keeping the temporary script file</p></li>
<li><p><strong>timeout</strong> – timeout</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>a dict with keys (‘exitstatus’, ‘result’)</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="cup.shell.expect.lscp">
<span class="sig-prename descclassname"><span class="pre">cup.shell.expect.</span></span><span class="sig-name descname"><span class="pre">lscp</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">src</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hostname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">username</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">passwd</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dst</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timeout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">800</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/cup/shell/expect.html#lscp"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#cup.shell.expect.lscp" title="Permalink to this definition">¶</a></dt>
<dd><p>copy [localhost]:src to [hostname]:[dst]</p>
<p>:return:a dict with keys (‘exitstatus’, ‘result’) exitstatus 0 success -1 others</p>
</dd></dl>

</section>
<section id="module-cup.shell.oper">
<span id="cup-shell-oper-module"></span><h2>cup.shell.oper module<a class="headerlink" href="#module-cup.shell.oper" title="Permalink to this heading">¶</a></h2>
<dl class="field-list simple">
<dt class="field-odd">description<span class="colon">:</span></dt>
<dd class="field-odd"><p>shell operations related module</p>
</dd>
</dl>
<dl class="py function">
<dt class="sig sig-object py" id="cup.shell.oper.backup_file">
<span class="sig-prename descclassname"><span class="pre">cup.shell.oper.</span></span><span class="sig-name descname"><span class="pre">backup_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">srcpath</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dstpath</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/cup/shell/oper.html#backup_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#cup.shell.oper.backup_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Backup srcpath/filename to dstpath/filenamne.label.
If label is None, cup will use time.strftime(‘%H:%M:S’)</p>
<dl class="field-list simple">
<dt class="field-odd">Dstpath<span class="colon">:</span></dt>
<dd class="field-odd"><p>will create the folder if no existence</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="cup.shell.oper.contains_file">
<span class="sig-prename descclassname"><span class="pre">cup.shell.oper.</span></span><span class="sig-name descname"><span class="pre">contains_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dstpath</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expected_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">recursive</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">follow_link</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/cup/shell/oper.html#contains_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#cup.shell.oper.contains_file" title="Permalink to this definition">¶</a></dt>
<dd><p>judge if the dstfile is in dstpath</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dstpath</strong> – search path</p></li>
<li><p><strong>dstfile</strong> – file</p></li>
<li><p><strong>recursive</strong> – search recursively or not. False by default.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>return True on success, False otherwise</p>
</dd>
</dl>
</dd></dl>

</section>
</section>


          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="index.html">cup</a></h1>








<h3>Navigation</h3>
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="cup.html">cup package</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="cup.html#subpackages">Subpackages</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="cup.net.html">cup.net package</a></li>
<li class="toctree-l3"><a class="reference internal" href="cup.res.html">cup.res package</a></li>
<li class="toctree-l3"><a class="reference internal" href="cup.services.html">cup.services package</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">cup.shell package</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#submodules">Submodules</a></li>
<li class="toctree-l4"><a class="reference internal" href="#module-cup.shell.expect">cup.shell.expect module</a></li>
<li class="toctree-l4"><a class="reference internal" href="#module-cup.shell.oper">cup.shell.oper module</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="cup.storage.html">cup.storage package</a></li>
<li class="toctree-l3"><a class="reference internal" href="cup.util.html">cup.util package</a></li>
<li class="toctree-l3"><a class="reference internal" href="cup.web.html">cup.web package</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="cup.html#submodules">Submodules</a></li>
<li class="toctree-l2"><a class="reference internal" href="cup.html#module-cup.cache">cup.cache module</a></li>
<li class="toctree-l2"><a class="reference internal" href="cup.html#module-cup.const">cup.const module</a></li>
<li class="toctree-l2"><a class="reference internal" href="cup.html#module-cup.decorators">cup.decorators module</a></li>
<li class="toctree-l2"><a class="reference internal" href="cup.html#module-cup.err">cup.err module</a></li>
<li class="toctree-l2"><a class="reference internal" href="cup.html#module-cup.exfile">cup.exfile module</a></li>
<li class="toctree-l2"><a class="reference internal" href="cup.html#module-cup.flag">cup.flag module</a></li>
<li class="toctree-l2"><a class="reference internal" href="cup.html#module-cup.log">cup.log module</a></li>
<li class="toctree-l2"><a class="reference internal" href="cup.html#module-cup.mail">cup.mail module</a></li>
<li class="toctree-l2"><a class="reference internal" href="cup.html#module-cup.platforms">cup.platforms module</a></li>
<li class="toctree-l2"><a class="reference internal" href="cup.html#module-cup.thread">cup.thread module</a></li>
<li class="toctree-l2"><a class="reference internal" href="cup.html#module-cup.timeplus">cup.timeplus module</a></li>
<li class="toctree-l2"><a class="reference internal" href="cup.html#module-cup.unittest">cup.unittest module</a></li>
<li class="toctree-l2"><a class="reference internal" href="cup.html#module-cup.version">cup.version module</a></li>
</ul>
</li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="index.html">Documentation overview</a><ul>
  <li><a href="cup.html">cup package</a><ul>
      <li>Previous: <a href="cup.services.html" title="previous chapter">cup.services package</a></li>
      <li>Next: <a href="cup.storage.html" title="next chapter">cup.storage package</a></li>
  </ul></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2023, CUP-DEV Team.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 7.0.1</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.13</a>
      
      |
      <a href="_sources/cup.shell.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>